package com.hongyue.dey02;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class Demo {
    public static void main(String[] args) {
        HashMap<String, String> hm = new HashMap<>();
        hm.put("贾乃亮", "李小璐");
        hm.put("王宝强", "荣荣");
        hm.put("羽凡", "白百合");
        Set<Map.Entry<String, String>> entries = hm.entrySet();
        for (Map.Entry<String, String> entry : entries) {
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println("丈夫：" + key + "\t 妻子：" + value);
        }
        System.out.println("------------------------");
        Iterator<Map.Entry<String, String>> iterator = entries.iterator();
        while (iterator.hasNext()) {
            Map.Entry<String, String> entry = iterator.next();
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println("丈夫：" + key + "\t 妻子：" + value);
        }
    }
}
